RWTH - Mindstorms NXT Toolbox

GetMotorSettings

Returns the current motor data / settings (e.g. position, speed, etc.) from the specified motor

Contents

Syntax

data = GetMotorSettings(port)

data = GetMotorSettings(port, handle)

Description

data = GetMotorSettings(port) returns the current motor data / settings of the given motor port. The value port can be addressed by the symbolic constants MOTOR_A , MOTOR_B and MOTOR_C analog to the labeling on the NXT Brick. The return value data is a struct variable. It contains several motor settings and information.

The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).

Output:

data.IsRunning % boolean, true if the motor "does something"

data.Power % current power

data.AngleLimit % current set angle limit, 0 means none set

data.TurnRatio % current turn ratio

data.SpeedRegulation % boolean, speed regulated or not?

data.SyncToMotor % the motor this one is synced to. -1 means not synced

data.TachoCount % internal, non-resettable rotation-counter (in degrees)

data.Angle % current motor position, resettable using, ResetMotorAngle

data.MotorBrake % boolean, is electronic braking enabled?

Example

   SetMotor(MOTOR_C);
   	SetPower(67);
   	SetAngleLimit(240);
   	SpeedRegulation('on');
   SendMotorSettings();

   WaitForMotor(MOTOR_C);

   data = GetMotorSettings(MOTOR_C);

See also

SendMotorSettings, ResetMotorAngle

Signature